package cn.edu.scau.cmi.wujiaxian.exercise11;

import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class WindowActionEvent2 extends JFrame{
	private static final long serialVersionUID = 4174621914605686809L;

	JTextField text;
	JTextArea textArea;
	JButton button;
	PoliceListen listener;
	
	public WindowActionEvent2() {
		init();
		setVisible(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	void init() {
		setLayout(new FlowLayout());
		text = new JTextField(10);
		button = new JButton("读取");
		textArea = new JTextArea(5, 18);
		listener = new PoliceListen();
		listener.setJTextField(text);
		listener.setJTextArea(textArea);
		text.addActionListener(listener); //注册监视器
		button.addActionListener(listener);
		add(text);
		add(button);
		add(new JScrollPane(textArea));
	}
	
}
